package com.ljw.vendingmachine.utils;

import android.annotation.SuppressLint;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;

import com.ljw.vendingmachine.R;
import com.ljw.vendingmachine.widget.BasePopupWindow;

public class LayoutUtil {
    @SuppressLint("WrongConstant")
    public static PopupWindow createPopupWindow(View contentView) {
        PopupWindow popupWindow = new BasePopupWindow(contentView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, true);
        popupWindow.setTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        popupWindow.setFocusable(true);
        popupWindow.setAnimationStyle(R.style.anim_menu_bottombar);
        popupWindow.setClippingEnabled(true);
        popupWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);


        popupWindow.update();
        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
             //setWindowBackgroundAlpha(1.0f);//当PopupWindow消失的时候Window完全透明
            }
        });
        return popupWindow;
    }

}
